package tdt4240.iddqd;

import javax.microedition.khronos.opengles.GL10;

import org.anddev.andengine.entity.scene.menu.MenuScene;
import org.anddev.andengine.entity.scene.menu.item.SpriteMenuItem;
import org.anddev.andengine.entity.text.Text;
import org.anddev.andengine.util.HorizontalAlign;

import tdt4240.iddqd.camera.GameCamera;

public class GameMenuScene extends MenuScene {

	private Text mNote;

	public GameMenuScene(GameCamera camera){
		this(camera, null);
	}

	public GameMenuScene(GameCamera camera, String note){
		super(camera);

		//A game event occured (won/lost)
		if(note != null && !"".equals(note.trim())) {
			mNote = new Text(camera.getWidth()*2/5, camera.getHeight()/6, GameActivity.mGameOverFont, note, HorizontalAlign.CENTER);
			attachChild(mNote);
		}
		//Player pressed menu button
		else {
			final SpriteMenuItem continueMenuItem = new SpriteMenuItem(Constants.MENU_RESET, GameActivity.mMenuContinueTextureRegion);
			continueMenuItem.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
			addMenuItem(continueMenuItem);
		}

		final SpriteMenuItem resetMenuItem = new SpriteMenuItem(Constants.MENU_RESET, GameActivity.mMenuResetTextureRegion);
		resetMenuItem.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
		addMenuItem(resetMenuItem);

		final SpriteMenuItem quitMenuItem = new SpriteMenuItem(Constants.MENU_QUIT, GameActivity.mMenuQuitTextureRegion);
		quitMenuItem.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
		addMenuItem(quitMenuItem);

		buildAnimations();

		setBackgroundEnabled(false);
	}


}
